(function() {
    if (app.documents.length === 0) {
        alert("请先打开一个文档。");
        return;
    }

    var sel = app.selection;

    if (sel.length === 0) {
        alert("当前没有选中任何对象。");
        return;
    }

    for (var i = 0; i < sel.length; i++) {
        var item = sel[i];
        var info = "对象索引：" + i + "\n";
        info += "构造类型（constructor.name）：" + item.constructor.name + "\n";

        // 父级信息
        var parentInfo = "无";
        try {
            if (item.parent) {
                parentInfo = item.parent.constructor.name;
            }
        } catch (e) {
            parentInfo = "未知";
        }

        info += "父级类型：" + parentInfo + "\n";

        alert(info);
    }
})();
